$(document).ready(function () {
    if (tab && tab == 'style3Tab2') {
        $('[href="#style3Tab2"]').click();
    }
    var form = new xhForm($('#xh_form'));
    form.parse();
    $('#sSubjects').select2();
    form.fill(tchInfo);
    if(tchInfo['sSubjects']!=null) {
        $('#sSubjects').val(tchInfo['sSubjects'].split(',')).trigger('change');
    }
    $('.from-date').datetimepicker({format: 'yyyy-mm-dd', language: 'zh-CN', minView: "month", autoclose: true});
    $('#save').click(function () {
        $.ajax({
            url:baseUrl+'frontend/Tch/saveTch',
            data:$('#xh_form').serialize(),
            type:'POST',
            success:function (data) {
                xhExtra.setBtnNormal($('#save'));
                window.top.swal(
                    data['msg'],
                    '',
                    'success'
                );
            },
            error:function (data) {
                xhExtra.setBtnNormal($('#save'));
                window.top.swal(
                    data['responseText'],
                    '',
                    'error'
                );
            }
        });
    });

});
